HyperPoint Events

The HyperPoint object contains the following events:

OnInitialize

Important: This event is obsolete. However, it is still available to existing points that use this event. It is unavailable to new points. This and other obsolete events appear in italics in the script editor event drop-down menu.

Called when the script engine initializes.

Syntax

HyperPointObject_OnInitialize()

Remarks

This event operates in the same manner as the Microsoft Visual Basic event of the same name. Use the OnInitialize event of an object or class to prepare the object or class for use, setting any references to sub-objects or assigning values to module-level variables. Note that points added to the Points object in this method will not be immediately available for use; to get data immediately, call the Points.ResolveNow or Points.UpdateNow methods first.

Example

The OnInitialize event is commonly used to initialize the Points object with points to be monitored, as in this example.

Copy
OnInitialize
Sub DEMOPNT_OnInitialize()
    Points.AddPoint "CYGDEMO.UIS:POINT1", DEMOPNT
    'some code
    . . .
End Sub

Back to top

OnInitializeEx

Called when the script engine initializes.

Syntax

HyperPointObject_OnInitializeEx(This)

Remarks

This event operates in the same manner as OnInitialize, but provides an additional parameter to make further scripting easier. The "This" parameter allows the scripter to self-reference the hyperpoint instead of typing out its full name.

Example

The following example shows the time that the point was intiliazed by self-referencing the point.

Copy
OnInitializeEx
Sub CYG_HSS_DEMOPNT_OnInitializeEx(This)
    'This is possible:
    MsgBox "Point initialized on " & This.Timestamp
     
    'As opposed to this:
    'MsgBox "Point initialized on " & CYG_HSS_DEMOPNT.Timestamp
End Sub

Back to top

OnPointChange

Called when a point is changed.

Syntax

HyperPointObject_OnPointChange(This, Tag)

Remarks

This event is fired when a point added through AddPoint or AddPointArray is modified. The "This" parameter allows the scripter to self-reference the hyperpoint instead of typing out its full name. The "Tag" parameter is the point tag of the point that has been changed.

Example

The following example demonstrates the OnPointChange event. When TESTPOINT is first initialized, it calls AddPoint and starts monitoring MonitoredPoint. When MonitoredPoint changes, the value of TESTPOINT is set to the current time.

Copy
OnPointChange
Sub TESTPOINT_OnInitialize()
    Points.AddPoint "CYGDEMO.UIS:MonitoredPoint", TESTPOINT
    End Sub
     
    Sub TESTPOINT_OnPointChange(This, Tag)
    This.VALUE = Time
End Sub

Back to top

OnTerminate

Important: This event is obsolete. However, it is still available to existing points that use this event. It is unavailable to new points. This and other obsolete events appear in italics in the script editor event drop-down menu.

Called when the script engine terminates.

Syntax

HyperPointObject_OnTerminate()

Remarks

This event operates in the same manner as the Visual Basic event of the same name. The OnTerminate event is fired when the last instance of an object or class is removed from memory. Instances of an object or class are removed from memory by explicitly setting the object variable to Nothing or by the object variable going out of scope.

Back to top

OnTerminateEx

Called when the script engine terminates.

Syntax

HyperPointObject_OnTerminateEx(This)

Remarks

This event operates in the same manner as OnTerminate, but provides an additional parameter to make further scripting easier. The "This" parameter allows the scripter to self-reference the hyperpoint instead of typing out its full name.

Example

The following example tells the user which point was terminated by self-referencing the point.

Copy
OnTerminateEx
Sub OnTerminateEx(This)
    MsgBox This.LongTag & " has been terminated"
End Sub

Back to top

OnTimer

Called when a timer event occurs.

Syntax

HyperPointObject_OnTimer(This)

Remarks

Timer events notify a HyperPoint when the timer’s countdown period expires. Before an event handler is invoked, the HyperPoint object is refreshed with the HyperPoint’s current contents from the HSS. After the handler completes, the HyperPoint contents in the HSS are updated from the HyperPoint object.

Example

The following example sets the value of the point to the time at which this event is invoked.

Copy
OnTimer
Sub DEMOPNT_OnTimer()
    'Set status of point to current time
    DEMOPNT.Value = Now
End Sub

Back to top

OnUpdate

Important: This event is obsolete. However, it is still available to existing points that use this event. It is unavailable to new points. This and other obsolete events appear in italics in the script editor event drop-down menu.

Called when a timer or point change event occurs.

Syntax

HyperPointObject_OnUpdate(EventType)

Parameters

Parameter Required Description

UpdateEventType

Yes

Defines the type of event that is occurring, which is either a timer event or a point value change event. Use the UpdateEventType table to access this value.

Remarks

OnUpdate has two UpdateEventTypes — a Point event and a Timer event. Functions are provided to notify a HyperPoint when a Point event occurs, such as Points.AddPoint. Timer events notify a HyperPoint when the timer’s countdown period expires. Before an event handler is invoked, the HyperPoint object is refreshed with the HyperPoint’s current contents from the HSS. After the handler completes, the HyperPoint contents in the HSS are updated from the HyperPoint object.

Example

The OnUpdate event is commonly used to obtain information from the Points object and perform related calculations. Also, it is good practice to use the value of a HyperPoint for its status. The following example of the OnUpdate event shows the status being updated and a UIS point receiving the value of the sum of two other UIS points — a calculation that will be executed each time OnUpdate is run. This example makes use of the global function SetPoint.

Copy
OnUpdate
Sub DEMOPNT_OnUpdate(EventType)
    'Set status of current point
    DEMOPNT.Value = "updated"
     
    'Get Point object(s) for points being monitored
    Set P1 = Points.Point("CYGDEMO.UIS:POINT1")
    Set P2 = Points.Point("CYGDEMO.UIS:POINT2")
     
    'Set the sum to a new point
    If IsNumeric(P1) And IsNumeric(P2) Then
        SetPoint "CYGDEMO.UIS:POINTSUM", CStr(P1.Value + P2.Value)
    End If
End Sub

Back to top